package demo2;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 98152
 * Date: 2024-05-27
 * Time: 16:16
 */
class MyThread implements Runnable {
    private int ticket = 5;
    public void run() {
        for (int i = 0; i < 100; i++) {
            if(ticket > 0) {
                System.out.println("卖票：ticket = " + ticket--);
            }
        }
    }
}
public class RunnableDemo02 {
    public static void main(String[] args) {
        MyThread my = new MyThread();
        Thread t1 = new Thread(my);
        Thread t2 = new Thread(my);
        Thread t3 = new Thread(my);
        t1.start();
        t2.start();
        t3.start();
    }
}
